﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Prism.WebBuilder.Script;
using Prism.WebBuilder.Lib.CArgs;
using System.Reflection;

namespace Prism.WebBuilder
{
	class Program
	{
		static void Main(string[] args)
		{
			CArgsProvider argsProvider = new CArgsProvider(args);
			if (argsProvider.PlainArgs.Count < 1)
			{
				ShowHint();
			}
			else	
			foreach (string scriptFile in argsProvider.PlainArgs)
			{
				PwbScript script = new PwbScript(scriptFile);
				if (argsProvider.Args.target == null)
				{
					Console.WriteLine(string.Format("error: specify --target in command line arguments"));
				}
				else
				{
					script.SetTarget(argsProvider.Args.target);
					script.Execute();
				}
			}			
		}

		static void ShowHint()
		{
			Console.WriteLine(string.Format("Prism.WebBuilder.exe {0}", Assembly.GetExecutingAssembly().GetName().Version.ToString()));
			Console.WriteLine(string.Format("Usage:"));
			Console.WriteLine(string.Format("  Prism.WebBuilder.exe script_path --target=TARGET_NAME"));
			Console.WriteLine(string.Format("Examples:"));
			Console.WriteLine(string.Format("  Prism.WebBuilder.exe test1.pwb --target=Release"));
		}
	}
}
